package studio.xiaoyun.core.exception;

/**
 * 所有自定义异常的超类
 * @author 岳正灵
 */
public class CoreException extends RuntimeException {

	private static final long serialVersionUID = -2097465532154739597L;
	private ErrorCode errorCode;
	public CoreException(String message){
		super(message);
	}
	
	public CoreException(ErrorCode errorCode,String message){
		super(message);
		this.errorCode = errorCode;
	}

	/**
	 * 取得异常码
	 * @return 异常码 , 如果没有设置异常码，则返回
	 * {@link studio.xiaoyun.core.exception.ErrorCode#INTERNAL_SERVER_ERROR INTERNAL_SERVER_ERROR}
	 */
	public ErrorCode getErrorCode(){
		return errorCode==null?ErrorCode.INTERNAL_SERVER_ERROR:errorCode;
	}
}
